package com.hdax.dm.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hdax.dm.entity.base.Image;
import com.hdax.dm.mappers.ImageMapper;
import com.hdax.dm.mapstrucs.CarouseDtoMapper;
import com.hdax.dm.service.ImageService;
import com.hdax.dm.utils.response.CommonResponse;
import com.hdax.dm.utils.response.ResponseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ImageSImpl extends ServiceImpl<ImageMapper, Image> implements ImageService {

    @Autowired
    private CarouseDtoMapper carouseDtoMapper;

    @Override
    public Image image(Long targetId, Long type, Long category) {
        QueryWrapper<Image> wrapper=new QueryWrapper<>();
        wrapper.eq("targetId",targetId);
        wrapper.eq("type",type);
        wrapper.eq("category",category );
        //getOne是ServiceImpl里的
        return getOne(wrapper);
    }

    @Override
    public CommonResponse<List<Image>> carousel() {
        QueryWrapper<Image> wrapper=new QueryWrapper<>();
        wrapper.eq("type",1L);
        wrapper.eq("category",1L);
        IPage<Image> page=page(Page.of(1,3),wrapper);
        return ResponseUtil.returnSuccess(page.getRecords());
    }

    /*@Override
    public CommonResponse<List<Image>> CarouselData(Integer itemTypeId) {
        QueryWrapper<Image> wrapper=new QueryWrapper<>();
        wrapper.eq("type",1L);
        wrapper.eq("category",1L);
        wrapper.eq("itemTypeId",itemTypeId);
        IPage<Image> page=page(Page.of(1,3),wrapper);
        return ResponseUtil.returnSuccess(page.getRecords());
    }*/
}
